AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )

include('shared.lua')

function ENT:Initialize()  
	self:SetModel(self.model);
	self.Entity:PhysicsInit(SOLID_VPHYSICS)
	self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
	self.Entity:SetSolid(SOLID_VPHYSICS)
	self.infot = ents.Create("info_target");
	self.infot:SetPos(self.Entity:GetPos());
	self.infot:Spawn();
	self.infot:Activate();
	self.infot:SetParent(self.Entity);
	self.infot.Warmelon = true;
	self.damaged = 0;
	self.infot.Team = self.Team; 
	self.maxhealth = (self.mass * server_settings.Int( "WM_healthtomass", 1.5));
	self.health = self.maxhealth;	
	local phys = self.Entity:GetPhysicsObject()
	if phys:IsValid() then
	   if phys:GetMass() ~= self.maxhealth / server_settings.Int( "WM_healthtomass", 1.5) then
	   phys:SetMass(self.mass)
	   end
phys:EnableMotion(1)
end
 	if (self.Team == 1) then
		self.Entity:SetColor (255, 0, 0, 255)
	end
	if (self.Team == 2) then
		self.Entity:SetColor (0, 0, 255, 255)
	end
	if (self.Team == 3) then
		self.Entity:SetColor (0, 255, 0, 255)
	end
	if (self.Team == 4) then
		self.Entity:SetColor (255, 255, 0, 255)
	end
	if (self.Team == 5) then
	self.Entity:SetColor (255, 0, 255, 255)
	end
	if (self.Team == 6) then
	self.Entity:SetColor (0, 255, 255, 255)
	end
end   
function ENT:Destruct()
    LS_Destruct(self.Entity)
end

function ENT:Damage()
	if (self.damaged == 0) then
		self.damaged = 1
	end
end 

function ENT:Think()
	self.BaseClass.Think(self)
	self.Entity:NextThink( CurTime() + 300)
	return true
end

function ENT:OnTakeDamage(DmgInfo)

		DamageLS(self.Entity, DmgInfo:GetDamage())
end

function ENT:OnRemove()
constraint.RemoveAll (self.Entity);
end